import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { GangFightsPlayerCellRenderer } from "./cellRenderer/GangFightsPlayerCellRenderer";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { SGangFightsTeamInfo } from "../../../../Message/Public/SGangFightsTeamInfo";
import { ObjTeamCreate } from "../common/ObjTeamCreate";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { GameDefConfig } from "../../resource/GameDefConfig";
import { GTileList } from "../../../../com/mui/controls/GTileList";
//class GangFightsTeamMsgWindow
    
    export  class GangFightsTeamMsgWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(430, 445);
            title = Language.getString(44535);
            titleHeight = 26;
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc1=null;
            super.createChildren();
            ObjCreate.createBg(18, 38, 395, 396, this);
            loc1 = new Object /* flash.display.Sprite */();
            loc1.mouseChildren = false;
            loc1.mouseEnabled = false;
            ObjCreate.setObjAttri(loc1, 17, 38, -1, -1, this);
            ObjCreate.createTextField(Language.getString(44543), 25, 5, 100, 20, loc1, GlobalStyle.textFormat6);
            ObjCreate.createBg(24, 31, 65, 65, loc1);
            this._bmpFace = new Object /* flash.display.Bitmap */();
            ObjCreate.setObjAttri(this._bmpFace, 25, 32, -1, -1, loc1);
            this._tfTeamName = ObjCreate.createTextField(Language.getString(44536), 113, 22, 250, 20, loc1);
            this._tfTeamScore = ObjCreate.createTextField(Language.getString(44537), 113, 45, 100, 20, loc1);
            this._tfTeamRank = ObjCreate.createTextField(Language.getString(44538), 275, 45, 100, 20, loc1);
            this._tfTeamWin = ObjCreate.createTextField(Language.getString(44539), 113, 68, 100, 20, loc1);
            this._tfTeamLose = ObjCreate.createTextField(Language.getString(44540), 275, 68, 100, 20, loc1);
            this._tfTeamWinPer = ObjCreate.createTextField(Language.getString(44541), 113, 91, 100, 20, loc1);
            this._tfTotalNum = ObjCreate.createTextField(Language.getString(44542), 275, 91, 100, 20, loc1);
            ObjCreate.createBg(20, 114, 363, 2, loc1, "SplitLine");
            this._tileList = ObjCreate.createTileList(17, 120, 360, 270, loc1);
            this._tileList.columnWidth = 360;
            this._tileList.rowHeight = 90;
            this._tileList.setStyle("cellRenderer", GangFightsPlayerCellRenderer);
            LoaderHelp.addResCallBack(ResFileConst.GangFightsFace, this.onResCompl);
            return;
        }

        public updateTeamInfo(arg1: SGangFightsTeamInfo): void
        {
            this._teamInfo = arg1;
            var loc1=arg1.winNum + arg1.loseNum;
            var loc2="0";
            if (loc1 > 0) 
            {
                loc2 = (arg1.winNum * 100 / loc1).toFixed(2);
            }
            ObjTeamCreate.setTextFieldKeyValue(this._tfTeamName, Language.getString(44536), arg1.name.toString());
            ObjTeamCreate.setTextFieldKeyValue(this._tfTeamScore, Language.getString(44537), arg1.mark.toString());
            ObjTeamCreate.setTextFieldKeyValue(this._tfTeamRank, Language.getString(44538), arg1.rank.toString());
            ObjTeamCreate.setTextFieldKeyValue(this._tfTeamWin, Language.getString(44539), arg1.winNum.toString());
            ObjTeamCreate.setTextFieldKeyValue(this._tfTeamLose, Language.getString(44540), arg1.loseNum.toString());
            ObjTeamCreate.setTextFieldKeyValue(this._tfTeamWinPer, Language.getString(44541) + loc2 + "%");
            ObjTeamCreate.setTextFieldKeyValue(this._tfTotalNum, Language.getString(44542), loc1.toString());
            this._tileList.dataProvider = new DataProvider(arg1.members);
            this.updateFace();
            return;
        }

        /* internal  */onResCompl(): void
        {
            this._isResCompl = true;
            this.updateFace();
            return;
        }

        /* internal  */updateFace(): void
        {
            if (this._isResCompl && this._teamInfo) 
            {
                this._bmpFace.bitmapData = GlobalClass.getBitmapData(GameDefConfig.instance.getGangFightsFaceName(this._teamInfo.faceId));
            }
            return;
        }

        public static get instance(): GangFightsTeamMsgWindow
        {
            if (!GangFightsTeamMsgWindow._instance) 
            {
                GangFightsTeamMsgWindow._instance = new GangFightsTeamMsgWindow();
            }
            return GangFightsTeamMsgWindow._instance;
        }

        /* internal */ /* var */_bmpFace: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfTeamName: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfTeamScore: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfTeamRank: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfTeamWin: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfTeamLose: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfTeamWinPer: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfTotalNum: Object /* flash.text.TextField */;

        /* internal */ /* var */_tileList: GTileList;

        /* internal */ /* var */_teamInfo: SGangFightsTeamInfo;

        /* internal */ /* var */_isResCompl: Boolean=false;

        /* internal */ static /* var */_instance: GangFightsTeamMsgWindow;
    }
